<?php
	if($_SERVER["REQUEST_METHOD"]=='POST') {
		$title			= strip_tags($_POST['title']);
		$detail			= $_POST['detail'];
		$url			= stripBlank($title);
		$ip				= getUserIP();

		$upload_fieldname	= 'thumb';
		$upload_fullpath	= '../contents/brand/'.md5('thumb'.time()). basename($_FILES[$upload_fieldname]['name']);
		if (move_uploaded_file($_FILES[$upload_fieldname]['tmp_name'], $upload_fullpath)) {
			$upload_basename = basename($upload_fullpath);
		}
 
		$sql = "INSERT INTO `tbl_brand` (`brand_id`, `title`, `url`, `detail`, `thumb`, `date`) VALUES (NULL, '$title', '$url', '$detail', '$upload_basename', NOW());";
		mysql_query($sql);
		redirect('../');
		exit;
	}

	include 'ckeditor/ckeditor.php';
	include 'ckeditor/ckfinder/ckfinder.php';
	
	$ckeditor = new CKEditor();
	$ckeditor->returnOutput			= true;
	$ckeditor->basePath				= '/backend/ckeditor/';
 
	CKFinder::SetupCKEditor($ckeditor, '/backend/ckeditor/ckfinder/');
	$detailHTML = $ckeditor->editor('detail');
?>